package dawnland03.model.action.impl;

import dawnland03.model.action.ActionImpl;
import dawnland03.model.action.parameter.ActionInputParam;
import dawnland03.model.action.parameter.ActionOutputParam;
import dawnland03.model.action.ActionType;
import dawnland03.model.action.handler.ActionHandler;
import dawnland03.model.entity.Entity;
import dawnland03.model.entity.attribute.PhysicalAttribute;

import java.util.Map;

/**
 * User: Petru Obreja (obrejap@yahoo.com)
 * Date: May 9, 2010
 * Time: 10:00:09 PM
 */
public class MoveAction extends ActionImpl {
    MoveAction(Entity owner, Map<ActionInputParam, Object> actionInputParams,
               Map<PhysicalAttribute, Integer> physicalAttributeRequirements,
               Map<PhysicalAttribute, Double> physicalAttributeMultiplier,
               long duration, ActionHandler actionHandler) {
        super(owner, ActionType.MOVE, actionInputParams,
                physicalAttributeRequirements, physicalAttributeMultiplier, duration, actionHandler);
    }

    @Override
    protected void endAction() {
        Integer destionationMatrixCellId = (Integer) actionInputParams.get(ActionInputParam.DESTINATION);
        Integer currentMatrixCellId = owner.getPosition().getMatrixCell().getId();
        outputParameters.addOutputParamValue(ActionOutputParam.STARTING_POSITION, currentMatrixCellId);
        outputParameters.addOutputParamValue(ActionOutputParam.DESTINATION, destionationMatrixCellId);
        owner.getPosition().setCoordinates(destionationMatrixCellId);
        outputParameters.addOutputParamValue(ActionOutputParam.COMPLETED, true);
        super.endAction();
    }
}
